<%@page import="java.net.URLDecoder"%>
<%@page import="org.ilead.iserve.model.SystemMessage"%>
<%@page import="org.ilead.iserve.service.manager.MessageManager"%>
<%@page import="java.util.Date"%>
<%@page import="org.ilead.iserve.model.PrivateMessage"%>
<%@page import="org.ilead.iserve.model.User"%>
<%@page import="org.ilead.iserve.constants.SessionKeyConstant"%>
<%@page import="java.util.Map"%>
<%@page import="org.ilead.iserve.service.manager.UserManager"%>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	boolean isInvalid = false;
	String action = request.getParameter("action");
	String title = request.getParameter("title");
	if(title != null && !"".equals(title))
		title = URLDecoder.decode(title, "UTF-8");
	String content = request.getParameter("content");
	if(content != null && !"".equals(content)){
		content = URLDecoder.decode(content, "UTF-8");
	}
	if("send".equalsIgnoreCase(action)){
		try{
			SystemMessage m = new SystemMessage();
			m.setSendTime(new Date());
			m.setContent(content);
			m.setTitle(title);
			MessageManager.getInstance().addSystemMessage(m);
			isInvalid = false;
		}catch(Exception e){
			isInvalid = true;
		}
	}
	//AJAX
	response.setContentType("text/xml");
	response.setHeader("Cache-Control","no-stroe");
	response.setHeader("pragma","no-cache");
	response.setDateHeader("Expries",0);
	String msg = "";
	if(isInvalid == true) {
		msg = "invalid";
	}else{
		msg = "validate";
	}
	response.getWriter().write("<msg>"+ msg +"</msg>");
%>
